#include "TestMaterials.h"
#include "TestGlasses.h"
#include "TestTangent.h"
#include "TestWater.h"
#include "TestAabb.h"
#include "TestGUI.h"
#include <gl/freeglut.h>
using namespace std;
using namespace egg;

TestScene* scene;

void render(void) {
    scene->render();
    glutSwapBuffers();
    string fps="fps:"+StringUtil::toString<int>(scene->getFPS());
    glutSetWindowTitle(fps.c_str());
}

void onMouseMove(int x,int y){
    scene->onMouseMove(x,y);
}

void onMouseButton(int button,int state,int x,int y){
    if(state==GLUT_DOWN){
        scene->onMouseDown(button,x,y);
    }else if(state==GLUT_UP){
        scene->onMouseUp(button,x,y);
    }
}

void onKeyboard(unsigned char kc,int x,int y){
    scene->onKeyboard(kc,x,y);
}

void init(){
    scene=new TestGUI();
    //scene=new TestAabb();
    //scene=new TestWater();
    //scene=new TestTangent();
    //scene=new TestGlasses();
    //scene=new TestMaterials();
    scene->init();
}

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(800,600);
    glutCreateWindow("eggine");
    glutKeyboardFunc(onKeyboard);
    glutMouseFunc(onMouseButton);
    glutPassiveMotionFunc(onMouseMove);
    init();
    glutIdleFunc(render);
    glutMainLoop();
    return 0;
}